package com.bruce.starts.demo.thread.lock;

import lombok.SneakyThrows;

public class Reader extends Thread{
    private Buffer buffer;

    public Reader(Buffer buffer) {
        this.buffer = buffer;
    }

    @SneakyThrows
    @Override
    public void run() {
        try {
            buffer.read();//可以收到中断的异常，从而有效退出
        } catch (InterruptedException e) {
            System.out.println("我不读了");
        }
        System.out.println("读结束");
    }
}
